package com.huaixia.cozeapi.service.impl;

import com.huaixia.cozeapi.clint.CozeApiClient;
import com.huaixia.cozeapi.config.CozeConfig;
import com.huaixia.cozeapi.dto.SubmitChatDTO;
import com.huaixia.cozeapi.service.CozeChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author biliyu
 * @date 2024/6/25 15:05
 */
@Service
public class CozeChatServiceImpl implements CozeChatService {

    @Autowired
    private CozeConfig cozeConfig;

    @Override
    public Object chat(SubmitChatDTO submitChatDTO) {
        CozeApiClient client = new CozeApiClient();
        Map<String, String> botTokenMap = cozeConfig.BotTokenMap();
        String token = botTokenMap.get(submitChatDTO.getBotId());
        return client.sendChatMessage(token, submitChatDTO.getBotId(), submitChatDTO.getConversationId(), submitChatDTO.getUser(), submitChatDTO.getQuery(), false);
    }



}
